home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / GMS / Source / Asm / Chunky / ChunkySingle.s < prev    next >
Encoding:
Text File  |  1997-05-11  |  4.1 KB  |  179 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Chunky Pixel List
  3. ;---------------
  4. ;This demo is like the other pixel list demos but uses a CHUNKY8 screen type.
  5. ;Then screen size has been kept very small as the C2P routine is too slow,
  6. ;but this will be improved in the next version.  The good thing is that
  7. ;because the routine is transparent, using a graphics card would mean that
  8. ;this demo would run at the maximum possible speed (ie the chunky screen
  9. ;would be displayable, so no c2p would be needed).
  10. ;
  11. ;Press LMB to exit.
  12.  
  13.     INCDIR    "INCLUDES:"
  14.     INCLUDE    "games/games_lib.i"
  15.     INCLUDE    "games/games.i"
  16.  
  17. CALL    MACRO
  18.     jsr    _LVO\1(a6)
  19.     ENDM
  20.  
  21.     SECTION    "DrawPixel",CODE
  22.  
  23. ;===========================================================================;
  24. ;                             INITIALISE DEMO
  25. ;===========================================================================;
  26.  
  27.     STARTGMS
  28.  
  29. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  30.     move.l    GMSBase(pc),a6
  31.     CALL    AllocBlitter
  32.     tst.l    d0
  33.     bne.s    .Error_Blitter
  34.  
  35.     lea    ScreenTags(pc),a0
  36.     CALL    ShowScreen
  37.     tst.l    d0
  38.     beq.s    .Error_Screen
  39.  
  40.     CALL    InitJoyPorts
  41.  
  42.     bsr.s    Main
  43.  
  44. .ReturnToDOS
  45.     move.l    GMSBase(pc),a6
  46.     move.l    Screen(pc),a0
  47.     CALL    DeleteScreen
  48. .Error_Screen
  49.     CALL    FreeBlitter
  50. .Error_Blitter
  51.     MOVEM.L    (SP)+,A0-A6/D1-D7
  52.     moveq    #ERR_OK,d0
  53.     rts
  54.  
  55. ;===========================================================================;
  56. ;                                MAIN LOOP
  57. ;===========================================================================;
  58.  
  59. Main:    move.l    Screen(pc),a0
  60.     lea    MList(pc),a2    ;a2 = Pointer to pixel list.
  61. .loop    moveq    #BUFFER1,d0
  62.     CALL    ClrScreen
  63.  
  64.     move.l    a2,a3    ;Drop the pixels here.
  65.     moveq    #31-1,d7
  66. .drop    addq.w    #1,2(a3)    ;a3 = YCoord+1
  67.     subq.l    #1,4(a3)    ;a3 = (Colour)-1
  68.     bge.s    .colok
  69.     clr.l    4(a3)
  70. .colok    addq.w    #8,a3
  71.     dbra    d7,.drop
  72.  
  73.     lea    MouseX(pc),a5
  74.     moveq    #JPORT1,d0
  75.     CALL    ReadMouse
  76.     btst    #MB_LMB,d0
  77.     bne.s    .done
  78.     move.w    d0,d1
  79.     ext.w    d1    ;d1 = Extend the Y byte.
  80.     add.w    d1,2(a5)    ;d1 = (MouseY)+ChangeY
  81.     asr.w    #8,d0    ;d0 = Extend the X byte.
  82.  
  83.     add.w    (a5),d0
  84. .ChkRX    cmp.w    GS_ScrWidth(a0),d0
  85.     blt.s    .ChkLX
  86.     move.w    GS_ScrWidth(a0),(a5)
  87.     bra.s    .Calculate
  88.  
  89. .ChkLX    tst.w    d0
  90.     bgt.s    .okX
  91.     clr.w    (a5)
  92.     bra.s    .Calculate
  93. .okX    move.w    d0,(a5)
  94.  
  95. .Calculate
  96.     move.l    (a5),-(sp)
  97.     moveq    #2,d1
  98.     CALL    FastRandom
  99.     subq.w    #1,d0
  100.     add.w    d0,(a5)
  101.  
  102.     moveq    #2,d1
  103.     CALL    FastRandom
  104.     subq.w    #1,d0
  105.     add.w    d0,2(a5)
  106.  
  107.     move.l    a2,a3
  108.     moveq    #31-1,d7
  109. .tloop    move.l    8(a3),(a3)
  110.     move.l    12(a3),4(a3)
  111.     addq.w    #8,a3
  112.     dbra    d7,.tloop
  113.  
  114.     lea    PixelList(pc),a1    ;a1 = Pixel list.
  115.     moveq    #BUFFER1,d0    ;d0 = Destination buffer.
  116.     CALL    DrawPixelList    ;>> = Draw pixels with clipping.
  117.     move.l    (sp)+,(a5)
  118.     CALL    WaitVBL
  119.     bra    .loop
  120. .done    rts
  121.  
  122. ;===========================================================================;
  123. ;                                  DATA
  124. ;===========================================================================;
  125.  
  126. ScreenTags:
  127.     dc.l    TAGS_GAMESCREEN
  128. Screen:    dc.l    0
  129.     dc.l    GSA_ScrWidth,256
  130.     dc.l    GSA_ScrHeight,128
  131.     dc.l    GSA_Palette,.palette
  132.     dc.l    GSA_AmtColours,32
  133.     dc.l    GSA_ScrType,CHUNKY8
  134.     dc.l    GSA_Attrib,CENTRE
  135.     dc.l    TAGEND
  136.  
  137. .palette
  138.     dc.l $000000,$101010,$171717,$202020,$272727,$303030,$373737,$404040
  139.     dc.l $474747,$505050,$575757,$606060,$676767,$707070,$777777,$808080
  140.     dc.l $878787,$909090,$979797,$a0a0a0,$a7a7a7,$b0b0b0,$b7b7b7,$c0c0c0
  141.     dc.l $c7c7c7,$d0d0d0,$d7d7d7,$e0e0e0,$e0e0e0,$f0f0f0,$f7f7f7,$ffffff
  142.  
  143. PixelList:
  144.     dc.w    32,PXL_SIZEOF    ;Amount of entries, EntrySize.
  145.     dc.l    MList    ;Pointer to pixel list array.
  146. MList    PIXEL    16,12,00    ;First pixel to draw (at back)
  147.     PIXEL    16,12,00    ;X/Y/Colour
  148.     PIXEL    16,12,00    ;..
  149.     PIXEL    16,12,00    ;..
  150.     PIXEL    16,12,00    ;..
  151.     PIXEL    16,12,00    ;..
  152.     PIXEL    16,12,00    ;..
  153.     PIXEL    16,12,00    ;..
  154.     PIXEL    16,12,00    ;..
  155.     PIXEL    16,12,00    ;..
  156.     PIXEL    16,12,00    ;..
  157.     PIXEL    16,12,00    ;..
  158.     PIXEL    16,12,00    ;..
  159.     PIXEL    16,12,00    ;..
  160.     PIXEL    16,12,00    ;..
  161.     PIXEL    16,12,00    ;..
  162.     PIXEL    16,12,00    ;..
  163.     PIXEL    16,12,00    ;..
  164.     PIXEL    16,12,00    ;..
  165.     PIXEL    16,12,00    ;..
  166.     PIXEL    16,12,00    ;..
  167.     PIXEL    16,12,00    ;..
  168.     PIXEL    16,12,00    ;..
  169.     PIXEL    16,12,00    ;..
  170.     PIXEL    16,12,00    ;..
  171.     PIXEL    16,12,00    ;..
  172.     PIXEL    16,12,00    ;..
  173.     PIXEL    16,12,00    ;..
  174.     PIXEL    16,12,00    ;..
  175.     PIXEL    16,12,00    ;..
  176.     PIXEL    16,12,00    ;..
  177. MouseX    PIXEL    16,12,31    ;Last pixel to draw (in front)
  178.  
  179.